package net.xdclass.strategy;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class ShardingTableConfig {
    /**
     * 存储库编号
     */
    private static final List<String> tablePrefixList = new ArrayList<>();

    static {
        tablePrefixList.add("0");
        tablePrefixList.add("a");
    }

    /**
     * 随机获取前缀
     */
    public static String getTableRandomPrefix(String code) {
        int index = Math.abs(code.hashCode());
        //对集合进行取模
        index = index % tablePrefixList.size();
        return tablePrefixList.get(index);
    }

}
